import { ApiProperty } from "@nestjs/swagger";
import { $Enums, SysUser } from "@prisma/client";

export class SysUserVo implements Omit<SysUser, "deletedAt" | "isSuper" | "password" | "isDeleted"> {
    @ApiProperty({ example: 1, description: "用户ID" })
    id: number;

    @ApiProperty({
        example: "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
        description: "头像URL"
    })
    avatar: string;

    @ApiProperty({ example: "admin", description: "用户名" })
    username: string;

    @ApiProperty({ example: "超级管理员", description: "用户昵称" })
    nickname: string;

    @ApiProperty({ example: false, description: "是否禁用" })
    isDisabled: boolean;
    @ApiProperty({ example: "127.0.0.1", description: "最后登录IP" })
    lastLoginIp: string;
    @ApiProperty({ description: "最后登录时间", example: "2023-01-01 12:00:00" })
    lastLoginAt: Date;
    @ApiProperty({ description: "创建时间", example: "2023-01-01 12:00:00" })
    createdAt: Date;
    @ApiProperty({ description: "更新时间", example: "2023-01-01 12:00:00" })
    updatedAt: Date;

    @ApiProperty({ description: "排序", example: 1 })
    sort: number;
    @ApiProperty({ description: "是否多点登录", example: false })
    isMultipoint: boolean;
    @ApiProperty({ description: "邮箱", example: "admin@example.com" })
    email: string;

    @ApiProperty({ description: "手机号", example: "13800138000" })
    phone: string;
    @ApiProperty({ description: "是否固定用户", example: false })
    isFixed: boolean;
    @ApiProperty({ description: "真实姓名", example: "张三" })
    realname: string;
    @ApiProperty({ description: "性别", example: "male", enum: $Enums.Gender })
    gender: $Enums.Gender;

    constructor(user: SysUser) {
        if (!user) throw new Error("User object is required");
        // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
        const { deletedAt, password, isDeleted, ...rest } = user;
        Object.assign(this, rest);
    }
}
